package design.pattern.Lu13AdapterPattern;

import java.util.HashMap;
import java.util.Map;

/**
 * @program JavaBase
 * @description: 适配器模式
 * @author: zhanglu
 * @create: 2020-04-09 14:06:00
 */
public class AdapterPattern {

    public static void main(String[] args) {

        UserInfo userInfo;
        userInfo = new UserInfo();
        for (int i = 0; i < 2; i++) {
            userInfo.username("username" + i);
            userInfo.mobileNumber("mobileNumber" + i);
            userInfo.homeAddress("homeAddress" + i);
            userInfo.homeTelNumber("homeTelNumber" + i);
            userInfo.jobPosition("jobPosition" + i);
            userInfo.officeTelNumber("officeTelNumber" + i);
            System.out.println("--------------------------");
        }

        OuterUserInfo outerUserInfo = new OuterUserInfo();
        for (int i = 0; i < 1; i++) {
            outerUserInfo.username("username" + i);
            outerUserInfo.mobileNumber("mobileNumber" + i);
            outerUserInfo.homeAddress("homeAddress" + i);
            outerUserInfo.homeTelNumber("homeTelNumber" + i);
            outerUserInfo.jobPosition("jobPosition" + i);
            outerUserInfo.officeTelNumber("officeTelNumber" + i);
            System.out.println("--------------------------");
        }

    }

}

interface IUserInfo{

    void username(String username);
    void mobileNumber(String mobileNumber);
    void homeAddress(String homeAddress);
    void homeTelNumber(String homeTelNumber);
    void officeTelNumber(String officeTelNumber);
    void jobPosition(String jobPosition);
}

class UserInfo implements IUserInfo{

    @Override
    public void username(String username) {
        System.out.println("人员姓名：" + username);
    }

    @Override
    public void homeAddress(String homeAddress) {
        System.out.println("家庭地址：" + homeAddress);
    }

    @Override
    public void mobileNumber(String mobileNumber) {
        System.out.println("手机号码：" + mobileNumber);
    }

    @Override
    public void officeTelNumber(String officeTelNumber) {
        System.out.println("办公电话：" + officeTelNumber);
    }

    @Override
    public void jobPosition(String jobPosition) {
        System.out.println("公司职称：" + jobPosition);
    }

    @Override
    public void homeTelNumber(String homeTelNumber) {
        System.out.println("家庭电话：" + homeTelNumber);
    }

}

interface IOuterUser{

    Map userBaseInfo();
    Map userOfficeInfo();
    Map userHomeInfo();

}

class OuterUser implements IOuterUser{

    @Override
    public Map userBaseInfo() {
        Map<String, Object> m = new HashMap<>();
        m.put("username", "张三");
        m.put("mobileNumber", "手机号码1");
        return m;
    }

    @Override
    public Map userOfficeInfo() {
        Map<String, Object> m = new HashMap<>();
        m.put("officeTelNumber", "办公电话1");
        m.put("jobPosition", "公司职称1");
        return m;
    }

    @Override
    public Map userHomeInfo() {
        Map<String, Object> m = new HashMap<>();
        m.put("homeAddress", "家庭地址1");
        m.put("homeTelNumber", "家庭电话1");
        return m;
    }
}

class OuterUserInfo extends OuterUser implements IUserInfo{

    @Override
    public void username(String username) {
        System.out.println(super.userBaseInfo().get("username"));
    }

    @Override
    public void mobileNumber(String mobileNumber) {
        System.out.println(super.userBaseInfo().get("mobileNumber"));
    }

    @Override
    public void homeAddress(String homeAddress) {
        System.out.println(super.userHomeInfo().get("homeAddress"));
    }

    @Override
    public void homeTelNumber(String homeTelNumber) {
        System.out.println(super.userHomeInfo().get("homeTelNumber"));
    }

    @Override
    public void officeTelNumber(String officeTelNumber) {
        System.out.println(super.userOfficeInfo().get("officeTelNumber"));
    }

    @Override
    public void jobPosition(String jobPosition) {
        System.out.println(super.userOfficeInfo().get("jobPosition"));
    }
}



